package com.java.base.exercise.util;

import com.java.base.exercise.People;

import java.util.*;
import java.util.stream.Collectors;

/**
 * @Author RenPu
 * @Date 2022/6/21 10:30
 * @Version 1.0
 * @Description:
 **/
public class TestUnquie {

    public static void main(String[] args) {
        List<Integer> list= new ArrayList<>();
        list.add(1);
        list.add(2);
        list.add(3);
        list.add(2);

        HashSet<Integer> integers = new HashSet<>(list);
        System.out.println(integers);

        if(integers.isEmpty()){
            System.out.println("hello world .....");
        }


        List<People> bookList = new ArrayList<>();
        bookList.add(new People("jack",12));
        bookList.add(new People("martin",null));
        // 空指针异常
        Map<String, Integer> collect = bookList.stream().collect(Collectors.toMap(People::getName, People::getSex));

        System.out.println(collect.entrySet());



    }


    static class Person {
        private String name;
        private String phoneNumber;

        public Person(String name, String phoneNumber) {
            this.name=name;
            this.phoneNumber=phoneNumber;

        }

        public String getName() {
            return name;
        }

        public void setName(String name) {
            this.name = name;
        }

        public String getPhoneNumber() {
            return phoneNumber;
        }

        public void setPhoneNumber(String phoneNumber) {
            this.phoneNumber = phoneNumber;
        }

        // getters and setters


        @Override
        public String toString() {
            return "Person{" +
                    "name='" + name + '\'' +
                    ", phoneNumber='" + phoneNumber + '\'' +
                    '}';
        }
    }



}
